import dayjs from 'dayjs';
import fly from "./config";
import store from './store.js'

let userId = ServerParam.UserId ? ServerParam.UserId : ""

let service  = {

    loadServerParam(){
        fly.get('/WorkFlowRuntime/Server/Param').then((res)=>{
            console.log(res)
            $(document.body).append('<script>' + res + '</script>');

        }).catch(error=>{
            console.error(error)
        })
    },

    loadCardInfo(date, type, format) {

        return new Promise((resolve, reject) => {
            let day = dayjs(date).format(format)
            fly.get('/OA_Attendence/CardTotal', {type: type, date: day, userid:userId}).then((res) => {
                console.log(res)
                resolve(res)

            }).catch(error => {
                reject(error)
                console.error(error)
            })
        })
    },
    loadCardDetail(date,userId){
        return new Promise((resolve, reject) => {
            let day = dayjs(date).format('YYYY-MM-DD')
            fly.get('/OA_Attendence/getusercard?', {date: day, userid:userId}).then((res) => {
                resolve(res)

            }).catch(error => {
                reject(error)
                console.error(error)
            })
        })
    }
}
export default service